<%@ page language="java" import="java.util.*,office.BusiUtil" pageEncoding="UTF-8"%>
<%@include file="/common/jsp/taglibs-nojs-nocss.jsp"%>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<div id="pop_up_content">
	<div class="pop_up_title images_1">
		新建出差单
	</div>
	<div class="pop_up_body">
		<form id="thisForm" action="saveTrip.action" method="post" >
		<table border="0" cellpadding="0" cellspacing="0"  width="400">
			<tr>
				<td>
					<div class="form_input_value">
						出差人
					</div>
				</td>
				<td>
					<input type="hidden" name="tripForm.id" value="<s:property value='tripForm.id'/>" >
					<input type="text" disabled="disabled" value="<s:property value='#session.user.userCname'/>" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						出差开始时间
					</div>
				</td>
				<td>
					<input type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" id="beginDate" name="tripForm.beginDate" value="<s:property value='tripForm.beginDate'/>" class="longinput required" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						出差结束时间
					</div>
				</td>
				<td>
					<input type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" id="endDate" name="tripForm.endDate" value="<s:property value='tripForm.endDate'/>" class="longinput required" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						出差总时长
					</div>
				</td>
				<td>
					<input type="text" id="sumTime" name="tripForm.sumTime" value="<s:property value='tripForm.sumTime'/>" class="longinput required" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						出差金额
					</div>
				</td>
				<td>
					<input id="tripMoney" type="text" name="tripForm.tripMoney" value="<s:property value='tripForm.tripMoney'/>" class="longinput">
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						礼品名称
					</div>
				</td>
				<td>
					<input id="giftName" type="text" name="tripForm.giftName" value="<s:property value='tripForm.giftName'/>" class="longinput">
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						出差原因
					</div>
				</td>
				<td>
					<textarea id='reson' name='tripForm.reson' class='dialogy_input max_length:500 required' rows='' cols='' style='width:320px;height:100px;overflow-y:scroll;overflow-x:hidden;margin-left: 8px;'><s:property value='tripForm.reson'/></textarea>
					<font color="red">【不能为空且字数限制500字】</font>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<input id="thisButton" type="button" onclick="return validateDate();" value="保存" class="btn" onmouseout="this.className='btn'" onmousedown="this.className='btn1'" onmouseover="this.className='btn2'">
					<input type="button" value="取消" class="btn" onclick="hideDialog();" onmouseout="this.className='btn'" onmousedown="this.className='btn1'" onmouseover="this.className='btn2'">
				</td>
			</tr>
		</table>
		</form>
	</div>
</div>
<script type="text/javascript">
	function validateDate(){
		var beginDate = document.getElementById('beginDate').value;
		var endDate = document.getElementById('endDate').value;
		if(beginDate == "" || endDate == ""){
			alert("起止时间不能为空！");
			return false;
		}
		beginDate=beginDate.replace(/-/g,"/");     
		endDate=endDate.replace(/-/g,"/");
		var   date1   =   Date.parse(beginDate);     
		var   date2   =   Date.parse(endDate);
		if(beginDate > endDate){
			alert('日期输入不合法！开始时间不能晚于结束时间。');
			document.getElementById('beginDate').value = "";
			document.getElementById('endDate').value = "";
			return false;
		}else{
			document.getElementById('sumTime').value = ((date2-date1)/(60*60*1000*24)+1).toFixed(1);
		}
		return true;
	}
	/* 表单提交 */
	i.formSubmit("thisButton",	//绑定的按钮id
					  "thisForm" ,   //提交的表单id
					  function(result){
						  	var jsonMsgObj=new JsonMsgObj(result);
							var  msg=jsonMsgObj.getMessage();
						    var codeId=jsonMsgObj.getCodeid();
							var isOk=jsonMsgObj.getIsok();
							if( isOk ){
							    aerouiAlert(msg);
								hideDialog();// 隐藏窗口
								window.location.reload();
							}else{		// 如果编辑失败了
							  JsManageInfoHandleException( result , function(msg , codeId , isOk){
							  		hideDialog();// 隐藏窗口
							   });
						   }
						});
</script>